package com.ruoyi.web.controller.yf;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yf.domain.YfDisinfect;
import com.ruoyi.yf.service.IYfDisinfectService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医废暂存点库房及医废车清洁消毒记录Controller
 * 
 * @author XiaoYi...
 * @date 2021-09-17
 */
@Controller
@RequestMapping("/yf/disinfect")
public class YfDisinfectController extends BaseController
{
    private String prefix = "yf/disinfect";

    @Autowired
    private IYfDisinfectService yfDisinfectService;

    @RequiresPermissions("yf:disinfect:view")
    @GetMapping()
    public String disinfect()
    {
        return prefix + "/disinfect";
    }

    /**
     * 查询医废暂存点库房及医废车清洁消毒记录列表
     */
    @RequiresPermissions("yf:disinfect:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YfDisinfect yfDisinfect)
    {
        startPage();
        List<YfDisinfect> list = yfDisinfectService.selectYfDisinfectList(yfDisinfect);
        return getDataTable(list);
    }

    /**
     * 导出医废暂存点库房及医废车清洁消毒记录列表
     */
    @RequiresPermissions("yf:disinfect:export")
    @Log(title = "医废暂存点库房及医废车清洁消毒记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YfDisinfect yfDisinfect)
    {
        List<YfDisinfect> list = yfDisinfectService.selectYfDisinfectList(yfDisinfect);
        ExcelUtil<YfDisinfect> util = new ExcelUtil<YfDisinfect>(YfDisinfect.class);
        return util.exportExcel(list, "disinfect");
    }

    /**
     * 新增医废暂存点库房及医废车清洁消毒记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存医废暂存点库房及医废车清洁消毒记录
     */
    @RequiresPermissions("yf:disinfect:add")
    @Log(title = "医废暂存点库房及医废车清洁消毒记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(YfDisinfect yfDisinfect)
    {
        return toAjax(yfDisinfectService.insertYfDisinfect(yfDisinfect));
    }

    /**
     * 修改医废暂存点库房及医废车清洁消毒记录
     */
    @GetMapping("/edit/{deptId}")
    public String edit(@PathVariable("deptId") Long deptId, ModelMap mmap)
    {
        YfDisinfect yfDisinfect = yfDisinfectService.selectYfDisinfectById(deptId);
        mmap.put("yfDisinfect", yfDisinfect);
        return prefix + "/edit";
    }

    /**
     * 修改保存医废暂存点库房及医废车清洁消毒记录
     */
    @RequiresPermissions("yf:disinfect:edit")
    @Log(title = "医废暂存点库房及医废车清洁消毒记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(YfDisinfect yfDisinfect)
    {
        return toAjax(yfDisinfectService.updateYfDisinfect(yfDisinfect));
    }

    /**
     * 删除医废暂存点库房及医废车清洁消毒记录
     */
    @RequiresPermissions("yf:disinfect:remove")
    @Log(title = "医废暂存点库房及医废车清洁消毒记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(yfDisinfectService.deleteYfDisinfectByIds(ids));
    }
}
